package com.df.ez_game.server;

import java.util.List;

/**
 * 负载均衡器
 * 支持可配置的负载均衡策略
 */
public class BrokerBalancer {
    private LoadBalanceStrategy strategy;
    
    public BrokerBalancer() {
        // 默认使用轮询策略
        this.strategy = new RoundRobinStrategy();
    }
    
    /**
     * 设置负载均衡策略
     * @param strategy 负载均衡策略实现
     */
    public void setStrategy(LoadBalanceStrategy strategy) {
        this.strategy = strategy;
    }
    
    /**
     * 选择Broker节点
     * @param brokers 可用的Broker节点列表
     * @return 选中的Broker节点
     */
    public BrokerInfo selectBroker(List<BrokerInfo> brokers) {
        return strategy.selectBroker(brokers);
    }
}
